package myProj1Answer;

public class Date {
	private String name;
	private int num;
	public Date(String inName, int inNum){
		this.name = inName;
		this.num = inNum;
	}
	public String getName(){
		return this.name;
	}
	public int getNum(){
		return this.num;
	}
	public boolean equals(Date other){
		return ((this.name.equals(other.getName()))&&(this.num==other.getNum()));
	}
	//divide by 100 to get monthNum, mod by 100 to get monthMax
	public static int monthNumMax(String inMon){ //note: there is a more elegant way to write this with arrays...
		switch (inMon){
		case "Jan": return 131;
		case "Feb": return 228;
		case "Mar": return 331;
		case "Apr": return 430;
		case "May": return 531;
		case "Jun": return 630;
		case "Jul": return 731;
		case "Aug": return 831;
		case "Sep": return 930;
		case "Oct": return 1031;
		case "Nov": return 1130;
		case "Dec": return 1231;
		default: return 0;
		}
	}
	public boolean after(Date prior){
		int month1 = monthNumMax(prior.getName())/100;
		int month2 = monthNumMax(this.name)/100;
		if (month2!=month1){
			return (month2>month1);
		} else {
			return (this.num>prior.num);
		}
	}
	public String toString(){
		return this.name+" "+this.num;
	}
}